import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:kmxy_base/base/base_page.dart';
import 'package:kmxy_base/page/setting/setting_page_state.dart';
import 'package:kmxy_base/widget/global_log_btn.dart';

/// 服务器地址设置界面
// ignore: must_be_immutable
class SettingPage extends BasePage {
  SettingPage({Key? key, arguments}) : super(key: key, arguments: arguments);

  @override
  SettingPageView createState() => SettingPageView();
}

class SettingPageView extends SettingPageState {
  @override
  Widget setPageContent(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        centerTitle: true,
        backgroundColor: Colors.white,
        foregroundColor: Colors.black,
        title: Text(
          '设置',
          style: TextStyle(
            color: Colors.black,
            fontSize: 16.sp,
            fontWeight: FontWeight.w700,
          ),
        ),
      ),
      body: SafeArea(
        child: Column(
          children: [
            Container(
              margin: EdgeInsets.only(left: 12.w, right: 12.w),
              child: TextField(
                controller: controller,
                maxLines: 1,
                decoration: const InputDecoration(
                  hintText: "请输入服务器IP",
                  labelText: '服务器IP',
                  icon: Icon(Icons.computer, color: Color(0xff00C15D)),
                ),
              ),
            ),
            InkWell(
              onTap: urlListF,
              child: Container(
                margin: EdgeInsets.only(left: 15.w, right: 15.w, top: 15.w),
                child: Text(
                  "当前服务器地址：$ipCurrent",
                  style: TextStyle(
                    color: const Color(0xFF333333),
                    fontSize: 18.sp,
                  ),
                ),
              ),
            ),
            Container(
              alignment: Alignment.centerLeft,
              margin: EdgeInsets.only(left: 15.w, right: 15.w, top: 15.w),
              child: Text(
                "APP版本：$version",
                style: TextStyle(
                  color: const Color(0xFF333333),
                  fontSize: 18.sp,
                ),
              ),
            ),
            Container(
              height: 20.w,
            ),
            Container(
              alignment: Alignment.center,
              width: 240.w,
              height: 42.w,
              decoration: BoxDecoration(
                color: const Color(0xff00C15D),
                // 圆角设置
                borderRadius: BorderRadius.circular(2),
              ),
              child: RawMaterialButton(
                onPressed: sureModify,
                child: Container(
                  alignment: Alignment.center,
                  width: double.infinity,
                  child: Text(
                    "确认修改",
                    style: TextStyle(
                      color: Colors.white,
                      fontSize: 16.sp,
                    ),
                  ),
                ),
              ),
            ),
            Container(
              height: 20.w,
            ),
            Container(
              alignment: Alignment.center,
              width: 240.w,
              height: 42.w,
              decoration: BoxDecoration(
                color: const Color(0xff00C15D),
                // 圆角设置
                borderRadius: BorderRadius.circular(2),
              ),
              child: RawMaterialButton(
                onPressed: defaultIp,
                child: Container(
                  alignment: Alignment.center,
                  width: double.infinity,
                  child: Text(
                    "默认地址",
                    style: TextStyle(color: Colors.white, fontSize: 16.sp),
                  ),
                ),
              ),
            ),
            Container(
              height: 20.w,
            ),
            Container(
              alignment: Alignment.center,
              width: 240.w,
              height: 42.w,
              decoration: BoxDecoration(
                color: const Color(0xff00C15D),
                // 圆角设置
                borderRadius: BorderRadius.circular(2),
              ),
              child: RawMaterialButton(
                onPressed: setLog,
                child: Container(
                  alignment: Alignment.center,
                  width: double.infinity,
                  child: Text(
                    GlobalLogBtn.isShowLogBtn ? "关闭LOG" : '打开LOG',
                    style: TextStyle(color: Colors.white, fontSize: 16.sp),
                  ),
                ),
              ),
            ),
            Container(
              height: 20.w,
            ),
            Container(
              alignment: Alignment.center,
              width: 240.w,
              height: 42.w,
              decoration: BoxDecoration(
                color: const Color(0xff00C15D),
                // 圆角设置
                borderRadius: BorderRadius.circular(2),
              ),
              child: RawMaterialButton(
                onPressed: cleanAppId,
                child: Container(
                  alignment: Alignment.center,
                  width: double.infinity,
                  child: Text(
                    "清除APP_ID",
                    style: TextStyle(color: Colors.white, fontSize: 16.sp),
                  ),
                ),
              ),
            ),
            Container(
              height: 20.w,
            ),
          ],
        ),
      ),
    );
  }
}
